﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using Bookvar.ObjectModel;

namespace Bookvar.UI.Converters
{
    public class ResourceTypeToVisibilityConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            var type = (ResourceType) value;
            var expectedType = (ResourceType) int.Parse( parameter.ToString(), CultureInfo.InvariantCulture );

            Visibility visibility = ( type == expectedType ) ? Visibility.Visible : Visibility.Collapsed;

            return visibility;
        }

        public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
        {
            throw new NotImplementedException("The method or operation is not implemented.");
        }

        #endregion
    }
}
